home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 May / EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso / earcd / util / dir / managers.lha / Managers / Dir / Dir.cli < prev    next >
Text File  |  1997-01-15  |  3KB  |  141 lines

  1. G4C
  2.  
  3. ; This GUI is similar to the Workbench "Execute command" GUI, but more.
  4. ; There is a textin gadget for entering commands, buttons for choosing
  5. ; files, changing the directory, and opening a newshell.
  6.  
  7. ; More important, it can also send ARexx commands to the port shown
  8. ; in the other (bottom right) textin gadget (which can also be changed)
  9.  
  10.  
  11. WinBig 10 30 520 38 "Enter commands :"
  12. WinSmall 0 -1 422 30
  13. WinType  11110010
  14.  
  15.  
  16. xOnLoad
  17. cl_Main = ""           ; our main variable.
  18. cl_Mode = G4C          ; Mode to run the command
  19. cl_Port = Gui4Cli      ; Name of default port (can also sendrexx to ourselves)
  20.  
  21. ; On opening we display the current directory in the titlebar (note large buffer)
  22.  
  23. xOnOpen
  24. setwintitle Dir.cli "$$CURRENT_DIR                                  "
  25. Update Dir.cli 1 $cl_Main    ; show whatever the command line is 
  26. SetGad Dir.cli 1 ON            ; to get the cursor in the gadget immediately
  27.  
  28. ; On quitting we delete the variables
  29.  
  30. xOnQuit
  31. delvar cl_#?
  32.  
  33. xOnRMB
  34. status
  35.  
  36.  
  37. ;================================> Main text input gadget
  38.  
  39. xTEXTIN 10 3 480 16 "" cl_Main "" 512
  40. gadid 1
  41. gosub Dir.cli DoCommand
  42.  
  43. xButton 495 4 20 14 C   ; clear the command line
  44. cl_Main = ""
  45. update dir.cli 1 ""
  46.  
  47.  
  48. ;========> Cycler for choosing ARexx/CLI/RUN modes
  49.  
  50. xCYCLER 10 20 80 14 "" cl_Mode
  51. GadID 10 ; we may want to change it from elsewhere
  52. CSTR ARexx     G4C
  53. CSTR CLI       CLI
  54. CSTR RUN       RUN
  55. CSTR Exec      EXEC
  56.  
  57.  
  58. ;========> GO button (to execute the command)
  59.  
  60. xBUTTON 90 20 40 14 "GO!"
  61. gosub Dir.cli DoCommand
  62.  
  63.  
  64. ;=======> button for file requester for commands
  65.  
  66. xbutton 135 20 65 14 "Cmd.."
  67. cl_cmd = ""
  68. REQFILE -1 -1 300 -60 "Choose Files" LOAD cl_cmd  sys:c
  69. if $cl_cmd > ""
  70.    cl_temp = $cl_Main
  71.    cl_Main = '$cl_cmd '
  72.    appvar cl_Main $cl_temp
  73.    update Dir.cli 1 $cl_Main
  74.    delvar cl_temp
  75. endif
  76.  
  77. ;========> Button for File requester for filenames
  78.  
  79. xBUTTON 200 20 65 14 "Files.."
  80. cl_File = ""
  81. REQFILE -1 -1 300 -60 "Choose Files" MULTI cl_File  $$CURRENT_DIR
  82. if $cl_File > ""
  83.    appvar cl_Main $cl_File
  84.    update Dir.cli 1 $cl_Main
  85. endif
  86.  
  87.  
  88. ;========> Button to open a shell
  89.  
  90. xBUTTON 265 20 40 14 Cli
  91. CLI 'Newshell "con:0/150/640/100/NewShell/CLOSE"'
  92.  
  93.  
  94. ;========> Button to change directory
  95.  
  96. xBUTTON 305 20 40 14 CD
  97. setvar cl_Dir ""
  98. REQFILE -1 -1 300 -60 "Choose directory" DIR cl_Dir ""
  99. if $cl_Dir > ""
  100.    CD $cl_Dir
  101.    SetWinTitle Dir.cli "$cl_Dir                                        "
  102. endif
  103.  
  104.  
  105. ;========> TEXTin gadget to get port name for sendrexx command
  106.  
  107. xTEXTIN 390 20 125 16 "Port" cl_Port "Gui4Cli" 40
  108. GadID 2
  109.  
  110.  
  111. ;========> ROUTINE to execute command
  112.  
  113. xROUTINE DoCommand
  114. docase $cl_Mode
  115. case  = G4C
  116.         SendRexx $cl_Port $cl_Main
  117.         SetWinTitle Dir.cli "Return : $$RETCODE $$REXXRET            "
  118.         break
  119. case  = CLI
  120.         CLI $cl_Main
  121.         SetWinTitle Dir.cli "Return : $$RETCODE"
  122.         break
  123. case  = RUN
  124.         RUN $cl_Main
  125.         SetWinTitle Dir.cli "Return : $$RETCODE"
  126.         break
  127. case  = EXEC
  128.         CLI 'execute $cl_Main'
  129.         SetWinTitle Dir.cli "Return : $$RETCODE"
  130.     break
  131. endcase
  132.  
  133.  
  134. ;=========> before commands are executed, we restore the window title
  135.  
  136. xBEFORE
  137. SetWinTitle Dir.cli "$$CURRENT_DIR                           "
  138.  
  139.  
  140.  
  141.